[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

MTR04_0819

MTR04_0819

Day05 從 Hash Anchor 看原生 History API (上)

Day05 從 Hash Anchor 看原生 History API (上)

[day-12]AJAX - 網路請求

[day-12]AJAX - 網路請求






留言討論